import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers';
import DefineOptions from 'unplugin-vue-define-options/vite';

const base = '/';

export default defineConfig(() => {
  return {
    resolve: {
      //设置别名
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    plugins: [
      vue(),
      DefineOptions(),
      AutoImport({
        resolvers: [ElementPlusResolver()]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ],
    server: {
      port: 5211,
      host: true,
      proxy: {
        '/nccommon': {
          changeOrigin: true,
          target: 'https://api-cdn.nowcoder.com'
        }
      }
    },
    base
  };
});
